cmake_minimum_required(VERSION 3.26)
project(opengl_template)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(3RD_DIR ${PROJECT_SOURCE_DIR}/3rd)

# glad
set(GLAD_DIR ${3RD_DIR}/glad)
add_subdirectory(${GLAD_DIR})
include_directories(${GLAD_DIR}/include)

# stb_image
set(STB_IMAGE_DIR ${3RD_DIR}/stb_image)
add_subdirectory(${STB_IMAGE_DIR})
include_directories(${STB_IMAGE_DIR})

# glfw
set(GLFW_DIR ${3RD_DIR}/glfw)
add_subdirectory(${GLFW_DIR})
include_directories(${GLFW_DIR}/include)

# glm
set(GLM_DIR ${3RD_DIR}/glm)
add_subdirectory(${GLM_DIR})
include_directories(${GLM_DIR})

# imgui
set(IMGUI_DIR ${3RD_DIR}/imgui-docking)
add_subdirectory(${IMGUI_DIR})
include_directories(${IMGUI_DIR})
include_directories(${IMGUI_DIR}/ImGuizmo)


file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_BINARY_DIR}/bin)


add_executable(opengl_template src/main.cpp
        src/Shader.cpp
        src/Shader.h
        src/Texture2D.cpp
        src/Texture2D.h
        src/Core.h
        src/renderer/Buffer.cpp
        src/renderer/Buffer.h
        src/renderer/VertexArray.cpp
        src/renderer/VertexArray.h
        src/platform/opengl/GlBuffer.cpp
        src/platform/opengl/GlBuffer.h
        src/platform/opengl/GlVertexArray.cpp
        src/platform/opengl/GlVertexArray.h
        src/renderer/Renderer.cpp
        src/renderer/Renderer.h
        src/renderer/RendererAPI.cpp
        src/renderer/RendererAPI.h
        src/renderer/RendererCommand.cpp
        src/renderer/RendererCommand.h
        src/platform/opengl/GlRendererAPI.cpp
        src/platform/opengl/GlRendererAPI.h
        src/renderer/FrameBuffer.cpp
        src/renderer/FrameBuffer.h
        src/platform/opengl/GlFrameBuffer.cpp
        src/platform/opengl/GlFrameBuffer.h
)
target_link_libraries(opengl_template PUBLIC
        std_image
        glad
        glfw
        glm::glm
        imgui
)